<?php

namespace app\airobot\controller;

use app\airobot\CommonLogic;
use app\airobot\model\OriginBoxRtp;
use think\admin\Controller;
use \PhpOffice\PhpSpreadsheet\IOFactory;
use think\Exception;
use think\facade\Db;
use think\facade\Log;

/**
 * 超管系统-RTP管理
 * Class Rtp
 * @package app\airobot\controller
 */
class BoxRtp extends Controller
{
    private $table = 'box_rtp';
    public $commonLogic;

    /**
     * RTP列表
     * @auth true
     */
    public function index()
    {
        $this->commonLogic = new CommonLogic();
        $this->title = '盲盒RTP列表';
        $query = $this->_query($this->table);
        $where = [];
        $query->where($where);
        $query->order('id asc')->page();
    }

    protected function _index_page_filter(array &$data)
    {
        foreach ($data as &$vo) {
            $vo = $this->dealDecimal($vo);
        }
    }

    public function dealDecimal($data)
    {
        foreach ($data as $key => $value) {
            if ($key == "user_value_5day" ||
                $key == "low" ||
                $key == "mid" ||
                $key == "high" ||
                $key == "rtp1" ||
                $key == "rtp2" ||
                $key == "rtp3" ||
                $key == "rtp4" ||
                $key == "k_ban" ||
                $key == "corr_value" ||
                $key == "corr_rtp") {
                $data[$key] = floatval($value);
            }
        }
        return $data;
    }
}